package com.artezio.buyndrive.domain;

import java.io.Serializable;
import javax.persistence.*;

@Entity
@Table(name = "carservice_parts")
//Связь таблиц автосервисы и запчасти с ценой автосервиса на запчасть
public class CarserviceParts implements Serializable {
    private static final long serialVersionUID = 1L;
    
    //Составной ключ
    @EmbeddedId
    protected CarservicePartsPK carservicePartsPK;

    //Цена 
    @Column(name = "cost")
    private Float cost;
    
    //Остаток на складе
    @Column(name = "quantity_in_stock")
    private Integer quantityInStock;

   
    @JoinColumn(name = "id_parts", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Parts parts;
    
    
    @JoinColumn(name = "id_carservice", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Carservice carservice;

    public CarserviceParts() {
    }

    public CarserviceParts(CarservicePartsPK carservicePartsPK) {
        this.carservicePartsPK = carservicePartsPK;
    }

    public CarserviceParts(Long idCarservice, Long idParts) {
        this.carservicePartsPK = new CarservicePartsPK(idCarservice, idParts);
    }

    public CarservicePartsPK getCarservicePartsPK() {
        return carservicePartsPK;
    }

    public void setCarservicePartsPK(CarservicePartsPK carservicePartsPK) {
        this.carservicePartsPK = carservicePartsPK;
    }

    public Float getCost() {
        return cost;
    }

    public void setCost(Float cost) {
        this.cost = cost;
    }

    public Parts getParts() {
        return parts;
    }

    public void setParts(Parts parts) {
        this.parts = parts;
    }

    public Carservice getCarservice() {
        return carservice;
    }

    public void setCarservice(Carservice carservice) {
        this.carservice = carservice;
    }
    
    public void setQuantityInStock(Integer quantityInStock) {
        this.quantityInStock = quantityInStock;
    }

    public Integer getQuantityInStock() {
        return quantityInStock;
    }
}
